<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增推广游戏')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-cpgame-add">
            
            <div class="form-group">    
                <label class="col-sm-3 control-label">游戏名称：</label>
                <div class="col-sm-8">
                    <input name="gameName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">拼音代码：</label>
                <div class="col-sm-8">
                    <input name="code" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">CP信息：</label>
                <div class="col-sm-8">
                    <input name="cpId" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">运营人员ID：</label>
                <div class="col-sm-8">
                    <input name="operationId" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">1:普通;2:专服：</label>
                <div class="col-sm-8">
                    <select name="operType" class="form-control m-b">
                        <option value="">所有</option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
             <div class="form-group">    
                <label class="col-sm-3 control-label">游戏评级：</label>
                <div class="col-sm-8">
                    <input name="rating" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">游戏类型 ：</label>
                <div class="col-sm-8">
                    <select name="gameType" class="form-control m-b">
                        <option value="">所有</option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">类型(IOS,Android)：</label>
                <div class="col-sm-8">
                    <select name="type" class="form-control m-b" >
                        <option value="">所有</option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否开放第三方登录：</label>
                <div class="col-sm-8">
                    <input name="loginControl" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否根据广告监控用户渠道归属(1 是、0 否)：</label>
                <div class="col-sm-8">
                    <input name="adveMonitoring" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">通道费：</label>
                <div class="col-sm-8">
                    <input name="slottingFee" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">CP分成：</label>
                <div class="col-sm-8">
                    <input name="rate" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">充值则扣：</label>
                <div class="col-sm-8">
                    <input name="rechargeDiscount" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">CPA分成比例：</label>
                <div class="col-sm-8">
                    <input name="cpaRate" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">CPS分成比例：</label>
                <div class="col-sm-8">
                    <input name="cpsRate" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">通知地址：</label>
                <div class="col-sm-8">
                    <textarea name="notifyUrl" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">appKey：</label>
                <div class="col-sm-8">
                    <textarea name="appKey" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">serverSecret：</label>
                <div class="col-sm-8">
                    <textarea name="serverSecret" class="form-control"></textarea>
                </div>
            </div>
            
            <div class="form-group">
               	<label class="col-sm-3 control-label">大logo：</label>
               	<div class="col-sm-8">
	               	<div class="fileinput fileinput-new" data-provides="fileinput">
				        <div class="fileinput-new thumbnail" style="width: 140px; height: 140px;">
				          <img />
				        </div>
				        <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div>
				        <div>
				          <span class="btn btn-white btn-file"><span class="fileinput-new text-navy">选择图片</span><span class="fileinput-exists text-warning">更改</span>
				          <input id="gameIconFullFile" name="gameIconFull" type="file"></span>
				          <a href="#" class="btn btn-white fileinput-exists text-danger" data-dismiss="fileinput">清除</a>
				        </div>
				    </div>
                </div>
         	</div>
            
              
            <div class="form-group">
                <label class="col-sm-3 control-label">小logo：</label>
                <div class="col-sm-8">
                	<div class="fileinput fileinput-new" data-provides="fileinput">
				        <div class="fileinput-new thumbnail" style="width: 140px; height: 140px;">
				          <img />
				        </div>
				        <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div>
				        <div>
				          <span class="btn btn-white btn-file"><span class="fileinput-new text-navy">选择图片</span><span class="fileinput-exists text-warning">更改</span>
				          <input id="gameIconFile" name="gameIcon" type="file"></span>
				          <a href="#" class="btn btn-white fileinput-exists text-danger" data-dismiss="fileinput">清除</a>
				        </div>
				    </div>
                </div>
            </div>
            
            <div class="form-group">    
                <label class="col-sm-3 control-label">注册单价：</label>
                <div class="col-sm-8">
                    <input name="unitPrice" class="form-control" type="text">
                </div>
            </div>


        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script type="text/javascript">
        var prefix = ctx + "cwsk/cpgame"
        $("#form-cpgame-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
            	if ($('#gameIconFullFile')[0].files[0] != null || $('#gameIconFile')[0].files[0] != null) {
            		uploadFile();
            	}else{
            		$.operate.save(prefix + "/add", $('#form-cpgame-add').serialize());
            	}
            }
        }
        
        function uploadFile() {
        	var formData = new FormData();
        	if ($('#gameIconFullFile')[0].files[0] != null ) {
        		formData.append('gameIconFullFile', $('#gameIconFullFile')[0].files[0]);
        	}
        	if ($('#gameIconFile')[0].files[0] != null) {
        		formData.append('gameIconFile', $('#gameIconFile')[0].files[0]);
        	}
        	
        	$.ajax({
        		url: prefix + "/add",
        		type: 'post',
        		cache: false,
        		data: formData,
        		processData: false,
        		contentType: false,
        		dataType: "json",
        		success: function(result) {
        			$.operate.successCallback(result);
        		}
        	});
        }
        
    </script>
</body>
</html>